<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="icon" href="../../favicon.ico">
    <title>WebOffice文档编辑器</title>
    <script src="./web-office-sdk-v1.1.17.umd.js"></script>

    <script>
       window.onload = async () => {
        var params=location.href.split("?")[1].split("&")
           var url = params[1].split("=")[1]
           var token = params[0].split("=")[1]

           window.wpsEditor = window.WebOfficeSDK.config({
                url:decodeURIComponent(url), // 如果需要通过js-sdk传递token方式鉴权，则需要包含_w_tokentype=1参数
                mount: document.querySelector('.custom-mount'),
                commonOptions: {
                    isShowTopArea: true, // 隐藏顶部区域(头部和工具栏)
                    isShowHeader: true // 隐藏头部区域
                },
                wordOptions:{
                    mobile:{
                        isOpenIntoEdit:true
                    }
                },
                cooperUserAttribute: {
                    isCooperUsersAvatarVisible: false //是否显示协作用户头像
                },
            })
            
            window.wpsEditor.iframe.style.height=window.innerHeight+"px"
           
            // 首次设置token和后续刷新token都是通过调用此API
            window.wpsEditor.setToken({token: token})
           
            window.wpsEditor.on('fileOpen', function(data) {
                console.log(data)

                wpsEditor.on('error', function(data) {
                    console.log(data)
                })
                wpsEditor.on('tabSwitch', function(data) {
                    console.log(data)
                })

                wpsEditor.on('fileStatus', function(data) {
                    console.log(data)
                    if(opener){
                        opener.fileStatus=data.status||data.Data.status
                    }
                })
            })

            await wpsEditor.ready()
            if(parent){
                parent.wpsEditor=window.wpsEditor
                parent.wordApp=wpsEditor.WordApplication()
            } 
            if(opener){
                opener.fileStatus=0
                opener.wordApp=wpsEditor.WordApplication()
            }
            
       }
      
    </script>
  </head>
  <body style="margin:0px;overflow-y: hidden;" >

    <div class="custom-mount" style="height: 100%;"/>
   
  </body>
</html>
